package com.offcn.common;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

public class WriteOutInfoCommon {

	
public static void startWriteOut(String str){
		
		System.out.println("正在执行创建文件夹操作");
		String path0 = "D:/code";
        String path1 = "D:/code/kkk.txt";
        File f = new File(path0);
        // 创建文件夹
        if (!f.exists()) {
            f.mkdirs();
        }
        f = new File(path1);
        // 创建文件
        if (!f.exists()) {
            try {
                f.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
		
		
		 OutputStream out = null;
		try {
			out = new FileOutputStream("D:/code/kkk.txt");
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} 
         byte[] b=str.getBytes();  
         try {
        	 System.out.println("正在执行写入操作");
			out.write(b);
		} catch (IOException e) {
			e.printStackTrace();
		} 
         try {
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}  
	}
	
}
